package com.emagic.manage.events;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by SH on 2017-02-27.
 */

public class ShareEvent {
    private final Result result;

    public ShareEvent(String json) {
        result = fromJSON(json);
    }

    public Result getResult() {
        return result;
    }

    private static Result fromJSON(String jsonString) {
        Result result = new Result();
        try {
            JSONObject json = new JSONObject(jsonString);
            result.setId(json.has("id") ? json.getString("id") : "");
            result.setUrl(json.has("url") ? json.getString("url") : "");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return result;
    }

    public static class Result {
        private String id;
        private String url;

        public String getId() {
            return id;
        }

        public void setId(String id) {
            this.id = id;
        }

        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        @Override
        public String toString() {
            return "Result{" +
                    "id='" + id + '\'' +
                    ", url='" + url + '\'' +
                    '}';
        }
    }
}

